package com.hgy.carsb.controller;

import com.fasterxml.jackson.databind.util.JSONPObject;
import com.hgy.carsb.entity.Total;
import com.hgy.carsb.service.RatioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Controller
@RequestMapping("/indicator")
public class IndicatorController {

    @Autowired
    private RatioService ratioService;

    private int year = 2020;
    private int month = 4;

    @PostMapping("/type")
    @ResponseBody
    public Total getTotal(@RequestParam("index")String command){
        switch (command){
            case "0":
                return ratioService.getTotal(year, month, "interest", "income", "FAW");
            case "1":
                return ratioService.getTotal(year, month, "dept", "asset", "FAW");
            case "2":
                return ratioService.getTotal(year, month, "asset", "income", "FAW");
            default:
                return new Total();
        }
    }
//    @GetMapping("/assetturnover")
//    public Total getAssetTurnoverTotal(){
//        return ratioService.getTotal(year, month, "asset", "income", "FAW");
//    }
//
//    @GetMapping("/profit")
//    public Total getProfitTotal(){
//        return ratioService.getTotal(year, month, "interest", "income", "FAW");
//    }
//
//    @GetMapping("/deptasset")
//    public Total getDeptAssetTotal(){
//        return ratioService.getTotal(year, month, "dept", "asset", "FAW");
//    }
}
